local skel = fk.CreateSkill {
  name = "emo__chanxiang",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__chanxiang"] = "缠香",
  [":emo__chanxiang"] = "锁定技，你无法响应男性角色使用的伤害牌。每当你受到男性角色造成的伤害后，其须对你使用一张【杀】，否则你获得其X张牌（X为本回合你累计受到的伤害数）。",

  ["#emo__chanxiang-slash"] = "缠香：你须对 %dest 使用一张【杀】，否则其获得你区域内 %arg 张牌",
}

skel:addEffect(fk.Damaged, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.from and data.from:isMale()
      and data.from ~= player and not data.from.dead
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = 0
    player.room.logic:getActualDamageEvents(1, function(e)
      if e.data.to == player then
        n = n + e.data.damage
      end
      return false
    end)
    local from = data.from
    if not from or from.dead then return end
    local use = room:askToUseCard(from, {
      pattern = "slash", prompt = "#emo__chanxiang-slash::"..player.id..":"..n,
      skill_name = skel.name,
      extra_data = {exclusive_targets = {player.id} , bypass_distances = true, bypass_times = true },
    })
    if use then
      use.extraUse = true
      room:useCard(use)
    elseif not player.dead and not from:isNude() and n > 0 then
      local cards = from:getCardIds("he")
      if #cards > n then
        cards = room:askToChooseCards(player, { target = from, min = n, max = n, flag = "he", skill_name = self.name})
      end
      room:obtainCard(player, cards, false, fk.ReasonPrey, player, skel.name)
    end
  end,
})

skel:addEffect(fk.CardUsing, {
  anim_type = "negative",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and data.card.is_damage_card and data.from:isMale()
  end,
  on_use = function (self, event, target, player, data)
    data.disresponsiveList = data.disresponsiveList or {}
    table.insertIfNeed(data.disresponsiveList, player)
  end,
})

return skel
